package conf

import "fmt"

type Db struct {
	User     string `yaml:"user"`
	Password string `yaml:"password"`
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	Db       string `yaml:"db"`
	Debug    bool   `yaml:"debug"`
}

func (d Db) GetDSN() string {
	//root:123456@tcp(127.0.0.1:3306)/go_db?charset=utf8mb4&parseTime=True
	return fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=True",
		d.User, d.Password, d.Host, d.Port, d.Db)
}

func (d Db) Empty() bool {
	return d.User == "" && d.Password == "" && d.Host == "" && d.Port == 0 && d.Db == ""
}
